package com.shadow.demo.decompilation;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Step4 {

    public static final List<Map<String, Object>> POM_INDEX = new ArrayList<>();

    public static void main(String[] args) {
        File root = new File(Config.TARGET2_DIRECTORY);
        buildPomIndex(root);
        System.out.println("----------end");
    }

    public static void buildPomIndex(File root) {
        if (!root.exists() || !root.isDirectory()) {
            System.out.println("路径无效");
            return;
        }
        File[] files = root.listFiles();
        if (files != null) {
            for (File file : files) {
                // ...
                Map<String, Object> index = new HashMap<>();
                index.put("file", file);
                if (file.isDirectory()) {
                    File pom = getPomFile2(file);
                    index.put("pom", pom);
                } else if (file.isFile()) {
                    System.out.println("不应该啊, 上一步异常");
                }
            }
        }
    }

    public static File getPomFile2(File file) {
        File r = null;
        if (file != null) {
            File[] files = file.listFiles();
            if (files != null) {
                for (File f : files) {
                    if (f.isFile() && f.getName().equals("pom.xml")) {
                        r = f;
                    } else if (f.isDirectory() && f.getName().equals("src")) {

                    } else {
                        System.out.println("错了错了");
                    }
                }
            }
        }
        return r;
    }


}
